/**
 * 
 */
package comint03.evaluator;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * @comint01_trunk, comint01.evaluator
 * @author dna
 */
public class Frame {

	private Map<Ident, Value> variables = new HashMap<Ident, Value>();
	
	public Frame(ArrayList<Ident> ids, ArrayList<Ident> locals, ArrayList<Value> args){
		if (ids.size() != args.size())
			throw new RuntimeException();

		for (int i =0; i< ids.size(); i++){
			variables.put(ids.get(i), args.get(i));
		}
		
		for (Ident id : locals) {
			variables.put(id, new Nil());
		}
	}
	
	public void set(Ident id, Value value){
		variables.put(id, value);
	}
	
	public Value get(Ident id){
		return variables.get(id);
	}
}
